package boardgamer.yavalath.client.resources;

import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import boardgamer.yavalath.R;
import boardgamer.yavalath.client.Settings;

import static com.google.common.base.Preconditions.checkNotNull;

public class SoundHandler {

  public static MediaPlayer buttonSound;
  public static MediaPlayer moveSound;
  public static AudioManager audioManager;

  public static void initialize(Context context) {
    audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    buttonSound = MediaPlayer.create(context, R.raw.button);
    moveSound = MediaPlayer.create(context, R.raw.cupdown);
  }

  public static void playWave(MediaPlayer mediaPlayer) {
    checkNotNull(mediaPlayer, "mediaPlayer");
    if (mediaPlayer != null && !Settings.instance().isMuted()) {
      mediaPlayer.start();
    }
  }
}
